package com.code.service.constants;

import com.code.service.message.HeartBeatMessage;

/**
 * @author ggh
 * @date 2023/4/15
 */
public enum MessageType {
    HEART_BEAT_MESSAGE((byte) 1, "心跳消息", HeartBeatMessage.class);

    private Byte type;

    private String msg;

    private Class parseClass;

    MessageType(Byte type, String msg, Class parseClass) {
        this.type = type;
        this.msg = msg;
        this.parseClass = parseClass;
    }

    public static MessageType parseType(Byte type) {
        for (MessageType messageType : values()) {
            if (messageType.getType().equals(type)) {
                return messageType;
            }
        }
        return null;
    }

    public Byte getType() {
        return type;
    }

    public String getMsg() {
        return msg;
    }

    public <T> Class<T> getParseClass() {
        return parseClass;
    }
}
